package com.manager;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ContactListAdapter extends ArrayAdapter<People> {

	List<People> items;
	
	public ContactListAdapter(Context context, int textViewResourceId,
			List<People> objects) {
		super(context, textViewResourceId, objects);
		this.items = objects;
	}

	@Override
    public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.customlistitem, null);
            }
            People o = items.get(position);
            if (o != null) {
                    TextView tt = (TextView) v.findViewById(R.id.toptext);
                    TextView bt = (TextView) v.findViewById(R.id.bottomtext);
                    if (tt != null) {
                          tt.setText(o.get_name() + " " + o.get_surname());
                          }
                    if(bt != null){
                          bt.setText(o.getAddress());
                    }
            }
            return v;
    }
}
